package model

/*******************************************************************************
Copyright:cloud
Author:cloudapex@126.com
Version:1.0
Date:2020-06-12
Description: 工具
*******************************************************************************/

import (
	"context"
	"service/ctrl"
	"service/model/mod"

	gpc "gitee.com/cloudapex/protos/comm/pb"
	gpb "gitee.com/cloudapex/protos/permis/pb"

	"google.golang.org/grpc"
)

var Tool tool

func init() {
	ctrl.GCon.RegistClienter(mod.GCONN_PERMIS, func(c *grpc.ClientConn) { Tool.cli = gpb.NewToolClient(c) })
}

type tool struct {
	cli gpb.ToolClient
}

// tool.CacheRole 获取某用户的角色缓存信息
func (this *tool) CacheRole(ctx context.Context, in *gpb.CacheRoleReq) (*gpb.CacheRoleRes, error) {
	return this.cli.CacheRole(ctx, in)
}

// tool.CacheRole 获取某路由的缓存信息
func (this *tool) CacheRoute(ctx context.Context, in *gpb.CacheRouteReq) (*gpb.CacheRouteRes, error) {
	return this.cli.CacheRoute(ctx, in)
}

// tool.CacheRole 重置缓存数据
func (this *tool) CacheReset(ctx context.Context, in *gpc.IdRequest) (*gpc.UnResponse, error) {
	return this.cli.CacheReset(ctx, in)
}
